y_or_n = input ("是否退出程序（输入y/n）：")
while y_or_n != 'y' :
    try:
        print ("请输入信息，并以空格分开")
        input_str=input("身高(米) 体重(公斤) 年龄 性别[男or女]:")
        str_list = input_str.split(' ')#注意打个空格
        height= float(str_list[0])
        weight= float(str_list[1])
        age= int(str_list[2])
        gender = str_list[3]
        def isBMR(a,b,c):
            if gender == "男":
                BMR = (13.7 * a) + (5.0 * b) - (6.8 * c) + 66
                print("BMR 数值为：{:.2f}大卡".format(BMR))
            elif gender == "女":
                BMR = (9.6 * a) + (1.8 * b) - (4.7 * c) + 655
                print("基础代谢率：{:.2f}大卡".format(BMR))
            else:
                print("暂不支持此性别！")
            return BMR
        def isBMI(a,b):
            bmi = a / pow(b, 2)
            print("BMI数值为：{}".format(bmi))
            who, nat = "", ""
            if bmi< 18.5:
                who, nat = "偏瘦", "偏瘦"
            elif 18.5 <= bmi < 24:
                who, nat = "正常", "正常"
            elif 24 <= bmi < 25:
                who, nat = "正常", "偏胖"
            elif 25 <= bmi < 28:
                who, nat = "偏胖", "偏胖"
            elif 28 <=bmi < 30:
                who, nat = "偏胖", "肥胖"
            else:
                who, nat = "肥胖", "肥胖"
            print("BMI 指标为:国际'{0}', 国内'{1}'".format(who, nat))
            return who,nat
        isBMI(weight,height)
        isBMR(weight,height,age)
        print()
        y_or_n = input("是否退出程序（输入y/n）：")
    except ValueError:
        print("身高，体重和年龄处请输入阿拉伯数字！")
        print()
    except NameError:
        print("身高，体重和年龄处请输入阿拉伯数字！")
        print()
    except TypeError:
        print("身高，体重和年龄处请输入阿拉伯数字！")
        print()
    except IndexError:
        print("身高，体重和年龄处请输入阿拉伯数字！")
        print()